﻿<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%option explicit%>
<%
Dim RZ_IN
RZ_IN=1
%>
<!--#include file="../conn.inc.asp" -->
<!--#include file="admin_inc/admin.function.asp" -->
<!--#include file="admin_inc/admin.sqlfunction.asp" -->
<%
checkadmin(4)
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>上传文件管理</title>
<link type="text/css" href="style/style.css" rel="stylesheet" rev="stylesheet"/>
<script type="text/javascript" src="admin_js/common.js"></script> 
<script type="text/javascript">
<!--
function deleteupload(){
	if(confirm("您确定要删除吗？")){
		document.getElementById("rzform2").submit();
	}
}
//-->
</script>
</head>
<body>
<%
dim rootuploadpath,subdir,filename,currentdir,dropfiles

dim appPath
appPath=replace(LCase(Request.ServerVariables("PATH_INFO")), "admin/manage_upload.asp","" )
If Left(RZ_UPLOAD_PATH,1)="/" Then
	rootuploadpath = RZ_UPLOAD_PATH&"/"
Else
	rootuploadpath = appPath&RZ_UPLOAD_PATH&"/"
End If
subdir=HTMLEncode(request("subdir"))
dropfiles=Trim(request("id"))
if subdir<>"" then
currentdir=rootuploadpath&subdir
else
currentdir=rootuploadpath
end if
currentdir=Replace(currentdir,"//","/")
%>
<form name="rzform" action="<%=Request.ServerVariables("URL")%>" method="post"  id="rzform"><div class="addrecord">
请选择目录：
<select name="subdir" id="subdir" onchange="changefolder(this);">
<option value="">根目录</option>
<%
dim fso,objFolder,objSubFolders,objSubFolder,subpath
set fso=server.CreateObject("scripting.filesystemobject")
on error resume next
set objFolder=fso.GetFolder(Server.Mappath(rootuploadpath))
set objSubFolders=objFolder.Subfolders
for each objSubFolder in objSubFolders 
subpath="/" + objSubFolder.name
Response.Write("<option value='"&subpath&"'")
if subdir=subpath then response.Write(" selected='selected'")
response.Write(">"&objSubFolder.name&"</option>")
next
set objFolder=nothing
set objSubFolders=nothing
set fso=nothing
%>
</select>

</div></form>
<form name="rzform2" id="rzform2" method="post">
<input type="hidden" id="subdir" name="subdir" value="<%=subdir%>"/>
<div class="uploadlist">
<%
On Error Resume Next
dim objFSO
Set objFSO=Server.CreateObject("Scripting.FileSystemObject")
If Err.Number=-2147221005 Then 
	Response.Write "您的主机不支持FSO,不能使用该功能"
	Err.Clear
	Response.End
End If
Function MultiProeces(str)
	Dim arr,i,result
	arr=Split(str,",")
	For i=0 To UBound(arr)
		result=result&","&Trim(arr(i))
	Next 
	MultiProeces=Mid(result,2)	
End Function 
If dropfiles<>"" Then
	dropfiles=MultiProeces(dropfiles)
	dropfiles=Split(dropfiles,",")
	Dim ii
	For ii=0 To UBound(dropfiles)
		Dim delfilepath
		delfilepath=currentdir&"/"&dropfiles(ii)
		delfilepath=Replace(delfilepath,"//","/")
		If objFSO.Fileexists(Server.Mappath(delfilepath)) Then
			objFSO.Deletefile(Server.Mappath(delfilepath))
		Else
			Response.Write delfilepath&"不存在"
		End If
	next
End If
dim folder
Set folder=objFSO.Getfolder(Server.Mappath(currentdir))
If Err.Number<>0 Then
    Response.Write ""&Err.Description&""
    Response.End
End If
dim photos,photoCount,pagesize,pageCount,page,i
Set photos=folder.Files
photoCount=photos.count
pagesize=20
pageCount=int(photoCount/pagesize)
page=GetIntQueryString("page")
If page<=1 Then 
   page=1
End If 
If photoCount Mod pagesize=0 Then
	pageCount= photoCount \ Cint(pagesize)
Else
	pageCount= photoCount \ Cint(pagesize)+1
End If
i=0
for Each filename In folder.files
	i=i+1
	If i>(page-1)*pagesize And i<=page*pagesize Then 
%>
<div class="photodiv">
<div class="titlediv">
<%=filename.name%></div>
	<a href="<%=currentdir%>/<%=filename.name%>"  target="_blank"><img src="<%=currentdir%>/<%=filename.name%>" width="140" height="100" border="0" alt="上传时间：<%=filename.datecreated%>"/></a><br/><input type="checkbox" name="id" id="id" value="<%=filename.name%>"/><%=FormatNumber(filename.size/1024,2)%>K
	<a href="?subdir=<%=subdir%>&id=<%=filename.name%>"  title="删除"  onclick="return confirm('您确定要删除吗？');"><img src="images/delete.gif" border="0" alt="删除" /></a>
</div>
<%
  	ElseIf i>Page*PageSize Then Exit For
  	End If
  	Next
%>
</div>
<div class="tdcenter" style="clear:both;margin-top:10px;"><input name="selectall" type="checkbox" id="selectall" value="" onclick="selectAll();" /><%out("lang_selectall")%>&nbsp;&nbsp;&nbsp;<input type="button" name="del" onclick="deleteupload();" value="<%out("lang_batchdelete")%>"/></div>
</form>

<div id="bottompage">
<ul>
	<% if page>1 then %>
	<li class='nextprev'>
	<a href="?subdir=<%=subdir%>&page=<%=page-1%>"><span>上一页</span></a> 
	</li>
	<%end if%>
	<% if page<pagecount then %>
	<li class='nextprev'>
	<a  href="?subdir=<%=subdir%>&page=<%=page+1%>"><span>下一页</span></a> 
	</li>
	<%end if%>
</ul><span class="recordcount">共<%=FormatNumber(folder.size/1024,2)%>K</span>
</div>
<%
    Set objFSO=Nothing
    Set folder=Nothing
%>
</body>
</html>